<template>
  <div id="app">
    <!-- <x-header slot="header" style="width:100%;position:absolute;left:0;top:0;z-index:100;" :left-options="leftOptions" :right-options="rightOptions" :title="title" :transition="headerTransition"></x-header> -->
    <!-- <transition :name="'vux-pop-' + (direction === 'left' ? 'in' : 'out')"> -->
    <transition :name="'vux-pop-' + (direction === 'left' ? 'in' : 'out')">
      <router-view class="router-view"></router-view>
    </transition>
  </div>
</template>

<script>
import { XHeader } from 'vux'
export default {
  name: 'App',
  components: {
    XHeader
  },
  data () {
    return {
      direction: 'right',
      isTabbarDemo: false,
      isHome: true
    }
  },
  computed: {
    // leftOptions () {
    //   return {
    //     // 返回按钮显示控制
    //     showBack: this.$route.name !== '源州游艇'
    //   }
    // },
    // rightOptions () {
    //   return {
    //     showMore: this.$route.name !== '源州游艇'
    //   }
    // },
    // headerTransition () {
    //   return this.direction === 'left' ? 'vux-header-fade-in-right' : 'vux-header-fade-in-left'
    // },
    // 路由控制header title 显示
    title () {
      return this.$route.name
    }
  },
  watch: {
    // 跳转动画控制
    $route (to, from, next) {
      // 如果isBack为true时，证明是用户点击了回退，执行right动画
      let isBack = this.$router.isBack
      if (isBack) {
        this.direction = 'right'
      } else {
        this.direction = 'left'
      }
      // 做完回退动画后，要设置成前进动画，否则下次打开页面动画将还是回退
      this.$router.isBack = false
      // const routeDeep = ['/', '/apply/consortia', '/rules/list', '/rules/add']
      // const toDepth = routeDeep.indexOf(to.path)
      // const fromDepth = routeDeep.indexOf(from.path)
      // console.log('to', toDepth)
      // console.log('from', fromDepth)
      // this.direction = toDepth > fromDepth ? 'left' : ''
    }
  }
}
</script>

<style lang="less">
@import "~vux/src/styles/reset.less";
@import "~vux/src/styles/1px.less";
@import "~vux/src/styles/tap.less";
@import url("../static/iconfont/iconfont.css");

html {
  font-size: 10px;
}
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  /* margin-top: 60px; */
  font-size: 10px;
  height: 100%;
}
.vux-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.3);
  z-index: 1;
}
.d-flex {
  display: flex;
  flex-wrap: wrap;
}
html,
body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}
.router-view {
  width: 100%;
  // top: 46px;
}
.vux-pop-out-enter-active,
.vux-pop-out-leave-active,
.vux-pop-in-enter-active,
.vux-pop-in-leave-active {
  will-change: transform;
  transition: all 500ms;
  height: 100%;
  // top: 46px;
  position: absolute;
  backface-visibility: hidden;
  perspective: 1000;
}
.vux-pop-out-enter {
  opacity: 0;
  transform: translate3d(-100%, 0, 0);
}
.vux-pop-out-leave-active {
  opacity: 0;
  transform: translate3d(100%, 0, 0);
}
.vux-pop-in-enter {
  opacity: 0;
  transform: translate3d(100%, 0, 0);
}
.vux-pop-in-leave-active {
  opacity: 0;
  transform: translate3d(-100%, 0, 0);
}
.content {
  height: 100%;
}
.goBack {
  position: absolute;
  width: 12px;
  height: 12px;
  border-style: solid;
  border-color: #488aff !important;
  border-width: 2px 0 0 2px;
  -webkit-transform: rotate(315deg);
  transform: rotate(315deg);
  top: 2px;
}
</style>
